@include("admin.layout.head")
<body>
<div class="x-body">
    <form  method="post" class="layui-form layui-form-pane">

        <div class="layui-form-item layui-form-text">
            <label class="layui-form-label">
                所属分类-{{$goods->cate->name}}
            </label>
            <table class="layui-table layui-input-block">
                <tbody>
                @foreach($goods->cate->norms as $norm)
                    <div class="layui-form-item">
                        <label class="layui-form-label">{{$norm->name}}</label>
                        <div class="layui-input-block">
                            <input type="text" name="{{$norm->id}}" lay-verify="title" autocomplete="off" placeholder="请输入商品属性值" class="layui-input">
                        </div>
                    </div>
                @endforeach
                </tbody>
            </table>
        </div>
        <div class="layui-form-item">
            <button class="layui-btn" lay-submit="" lay-filter="add">增加</button>
        </div>
    </form>
</div>
<script>
    layui.use(['form', 'layer'], function () {
        $ = layui.jquery;
        var form = layui.form
        var layer = layui.layer;

        //监听提交
        form.on('submit(add)', function (data) {
            $.ajax({
                url:"/admin/editKucun",
                type:"post",
                data:{'field':data.field,'goods_id':{{$goods->id}}},
                dataType:"json",
                success:function (msg) {
                    if(msg.error == 0){
                        layer.alert(msg.info, {icon: 6}, function () {
                            var index = parent.layer.getFrameIndex(window.name);
                            parent.layer.close(index);
                        });
                    }
                }
            });
            return false;
        });
    });
</script>

</body>

</html>